<?php html::docType() ?>
<html>
<head>
	<?php html::head() ?>
	<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="container">
		<?php html::navBar2() ?>
		<?php html::flash() ?>
		<div id="content">	 
			<div class="section" id="main">
				<div class="section-title">
					<h1 class="page-name">Venues </h1>
					<span class="title-sub"><a href="">Add a new venue</a></span>
				</div>
				<?php
					if(isset($view->request)){
						echo <<<HTML
						<div class="showing-results">
							<h2 class="showing-results">Results for: Venue: "{$view->request['venue_name']}" and Suburb: "{$view->request['suburb_name']}"</h2>
						</div>
HTML;
					}
					?>
				<div>
				<?php
					$markers="";
					$char=65;
					foreach($view->venues as $venue){
						$ratingElem = getRatingElement('venue', $venue['id'] ,$venue['rating']);
						
						$street=urlencode($venue['street']);
						$suburb=urlencode($venue['suburb']['name']);
						$markerLetter = chr($char++);
						$marker = "&markers=color:blue|label:$markerLetter|$street+$suburb+VIC+Australia";
						$markers = "$markers $marker";
						echo <<<HTML
						<div class="beer-result">
							<div class="offer-venuename">
							<span class="venue-name">
								<a href=router.php?c=venue&a=view&id={$venue['id']}>{$venue['name']}</a>&nbsp;&nbsp;$ratingElem
							</span>
							</div>
							<div class="offer-description">
								<span class="offer-beers">
								{$venue['street']} - {$venue['suburb']['name']} - {$venue['postcode']['postcode']}
								</span>
								<span class="title-sub"><a href=router.php?c=venue&a=view&id={$venue['id']}>more info</a></span>
							</div>
						</div>
HTML;
					}
					
					?>
					<div class=pagination>
							<a href="<?php echo $view->prevPageLink ?>">Prev</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?php echo $view->nextPageLink ?>">Next</a>&nbsp;&nbsp;
					</div>
				</div>
			</div>
		<div id="side">
			<div class="section" id="search">
				<div class="section-title">
					<h3>Search for a venue</h3>
				</div>
				<form action="router.php" method="GET" accept-charset="utf-8">
					<input type="text" id="beer-search" name="venue_name" value="VenueName">
					<select name="suburb_name"  id="search-suburb">
							<option value="">Suburb</option>
							<?php
								foreach ($view->suburbs as $suburb) {
									echo "<option value=\"$suburb[name]\">$suburb[name]</option>";
							}?>
					</select>
					<input type="submit" id="search-button"value="Search" />
					<input type="hidden" name="c" value="venue" />
					<input type="hidden" name="a" value="find" />
				</form>
			</div>
			<div class="section" id="map-side">
				<div class="section-title">
					<h3>Map</h3>
					
				</div>
				<div class="offer-list-map">
					<img src="http://maps.google.com/maps/api/staticmap?size=300x300&maptype=roadmap<?php echo $markers?>&sensor=false"/>
            	</div>
			</div>
		</div>
	</div>
	<?php html::footer2()?>
</div>
</body>
</html>
